﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using Public;
using System.Globalization;

namespace WebsiteAdmin.Salomon.Setting.Handler
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class ConfUpdate : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int rtn = 0;
            if (Cookie.AdminLoginName != null || Cookie.AdminLoginName != "")
            {
                string txbSiteName = context.Request["SiteName"].Trim();					//介绍标题
                string txbSiteKeywords = context.Request["SiteKeywords"].Trim();					//介绍标题
                string txbSiteDescription = context.Request["SiteDescription"].Trim();					//介绍标题     

                string txbSiteICP = context.Request["SiteICP"].Trim();
                string txbHotLine = context.Request["HotLine"].Trim();
                string txbEmail = context.Request["Email"].Trim();


                int txbIsOpen = Convert.ToInt32(context.Request["IsOpen"].Trim(), CultureInfo.InvariantCulture);	//显示顺序
                int txbIsReg = 0;	//显示顺序

                rtn = DoUpdate(
                    txbSiteName,
                    txbSiteKeywords,
                    txbSiteDescription,
                    txbSiteICP,
                    txbHotLine,
                    txbEmail,
                    txbIsOpen,
                    txbIsReg
                );
            }
            context.Response.Write((rtn == 1) ? "{ \"Done\": \"Success\" }" : "{ \"Done\": \"Failed\" }");
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

        private static int DoUpdate(
                string txbSiteName,
                string txbSiteKeywords,
                string txbSiteDescription,
                string txbSiteICP,
                string txbHotLine,
                string txbEmail,
                int txbIsOpen,
                int txbIsReg
            )
        {
            return
                Bll.ConfigInfo.Update(
                    Global.ConSalomon,
                    txbSiteName,
                    txbSiteKeywords,
                    txbSiteDescription,
                    txbSiteICP,
                    txbHotLine,
                    txbEmail,
                    txbIsOpen,
                    txbIsReg
                );
        }
    }
}
